//
// Created by AnTler on 2018/11/30.
//

#include "CommonUtils.h"

#include "LuaJavaHelper.h"

#include "JNIDef.h"

namespace CommonUtils {

    void print(const char *msg) {
        JNIEnv *env = LuaJavaHelper::getInstance()->getEnv();
        if (!env) {
            return;
        }

        ScopedLocalRef<jstring> jstr(env, env->NewStringUTF(msg));
        if (jstr) {
            LuaJavaHelper::callVoidMethod(env, LuaJavaHelper::getInstance()->getCallbackObj(),
                                          METHOD_NAME_PRINT, METHOD_SIG_PRINT,
                                          (jstring) jstr);
        }
    }

    void sleep(int timeoutMS) {
        LuaJavaHelper::getInstance()->sleep(timeoutMS);
    }
};